<template>
   	<div class="container" v-title data-title='编辑客户'>
		<Header title="编辑客户"></Header>
		<ul class="list-info-view">
			<li>
				<div class="unified-template">
					<div class="template-row-list">
						<label class="label-title">姓&emsp;&emsp;&emsp;&emsp;名</label>
						<div class="row-content">
							<input type="text" placeholder="请输入姓名" class="routineInput" v-model="name"/>
						</div>
					</div>
				</div>
			</li>
			<li>
				<div class="unified-template">
					<div class="template-row-list">
						<label class="label-title">称&emsp;&emsp;&emsp;&emsp;谓</label>
						<div class="row-content">
							<div  class="checkbox-list">
								<label>
	                              <input type="radio" value="0" v-model="gender">男
	                            </label>
	                            <label>
	                              <input type="radio" value="1" v-model="gender">女
	                            </label>
                            </div>
						</div>
					</div>
				</div>
			</li>
		</ul>
		<div class="line bor-b"></div>
		<textarea class="routineTextarea" placeholder="请描述客户意向，包括户型，面积等" v-model="remark"></textarea>
		<button class="btn-block" @click="btnSubmit" v-show="btnShow">保存</button>
	</div>
</template>
<script>
	export default{
		data(){
			return {
				id: this.$route.params.id,
				name: this.$route.params.name,
				gender: this.$route.params.gender,
				remark: this.$route.params.remark,
				btnShow: true
			}
		},
		components: {

		},mounted:function(){
            
		},
		methods:{
			btnCancel(){
				var id=this.$route.params.id;
				this.$router.push({name: 'declareDetail',params:{id:id}})
			},
			btnSubmit(){
				var _self = this;
				var flag = true;
				if(!_self.name){
					flag = false;
					layer.msg("请填写姓名",{
						time: 2000
					});
					return false;
				}
				if(!_self.gender){
					flag = false;
					layer.msg("请选择客户性别",{
						time: 2000
					});
					return false;
				}
				if(!_self.remark){
					flag = false;
					layer.msg("请填写客户意向",{
						time: 2000
					});
					return false;
				}
				if(flag){
					_self.btnShow = false;
					var params = {};
					params.id = _self.id;
					params.name = _self.name;
					params.gender = _self.gender;
					params.remark = _self.remark;
					var body = {};
					body.params = params;
					var url = this.utilHelper.apiUrl+'/api/editCPCusInfo';
					this.$http.post(url, body).then((response)=>{
						var body = response.body;
						if(body.result == 1){
							layer.msg("操作成功",{
								time: 2000
							}, function(){
								_self.btnShow = true;
								_self.$router.push({name: 'declareDetail',params:{id:params.id}})
							});
						}else{
							_self.btnShow = true;
							layer.msg("操作失败:"+body.resultMsg, {
								time: 2000
							});
						}
					});
				}
			}
		}
	}
	
</script>